package com.gs.netty.support;



import com.gs.netty.websocket.remoting.WebSocketInvocation;
import com.gs.netty.websocket.remoting.req.Request;
import com.gs.netty.websocket.remoting.resp.Response;
import io.netty.channel.ChannelHandlerContext;

import java.util.Objects;

public abstract class SocketProcessor implements Runnable{

    /**
     * 响应
     */
    protected ChannelHandlerContext response;
    /**
     * 请求
     */
    protected WebSocketInvocation request;

    public SocketProcessor(WebSocketInvocation request , ChannelHandlerContext response) {
        this.response = response;
        this.request = request;
    }



    public void reset(WebSocketInvocation request ,ChannelHandlerContext response) {
        Objects.requireNonNull(request);
        this.response = response;
        this.request = request;
    }

    @Override
    public final void run() {
        doRun();
    }

    protected abstract void doRun();


    public WebSocketInvocation getRequest() {
        return request;
    }

    public ChannelHandlerContext getResponse() {
        return response;
    }

}
